package com.congiya;

public class CharToNumber {

	public static void main(String[] args) {
		
		String p = "AB";
		String q = "BC";
		String r = "100";
		
		String pqr = p.concat(q).concat(r);
		System.out.println("pqr : " + pqr);
		
		pqr = pqr.replaceAll("[0-9]", "");
		System.out.println("pqr : " + pqr);				
				
		//getFor(p, pqr);		
		//getFor(q, pqr);
		//getFor(r, pqr);
		
		//findNumber();
		
		//for(int i=0; i<10; i++) {
			
			if(getLeft(1, p) + getRight() == getEquals()) {
				
				//System.out.println();
			}
		//}
	}
	
	public static void getFor(String strNum, String pqr) {
		
		int str_idx = 0;
		int str_len = strNum.length();
		String str_arrs[] = new String[str_len];
		int start_arrs[] = new int[str_len];
		int has_arrs[] = new int[str_len];
		do {
			
			str_arrs[str_idx] = strNum.substring(str_idx, str_idx+1);			
			start_arrs[str_idx] = (str_idx == 0) ? 1 : 0;
			has_arrs[str_idx] = getHasIdx(str_arrs[str_idx], pqr);						
			
			str_idx++;
		} while(str_idx < str_len);	
		
		showFor(str_arrs);
	}

	public static int findNumber(String str) {
		int str_len = str.length();
		int return_val = 1;
		
		if(str_len > 1)
			return_val = findNumber(str.substring(0, 1)) + findNumber(str.substring(1, 2));
		
		System.out.println("return_val : " + return_val);
		
		return return_val;
	}
	
	public static int getLeft(int i, String str) {
		
		int str_len = str.length();
		int return_val = 1;
		
		if(str_len > 1)
			return_val = (i* (int)Math.pow(10, str_len-1)) + getLeft(i, str.substring(1, 2));
			//return_val = getLeft(i, str.substring(0, 1)) + getLeft(i, str.substring(1, 2));
		
		System.out.println("return_val : " + return_val +", str : " + str);
		
		return return_val;
	}
	
	public static int getRight() {
		
		return 1;
	}
	
	public static int getEquals() {
		return 1;
	}
	
	public static void findNumber() {

		int depth = 0;
		
		for(int i=0; i<10; i++) {
			
			for(int k=0; k<10; k++) {
								
				for(int m=0; m<10; m++) {
					
					for(int n=0; n<10; n++) {
					
						if(i * Math.pow(10, 1) + k * Math.pow(10, 0)
								+ m * Math.pow(10, 1) + n * Math.pow(10, 0) == 100)
						{
							System.out.println(i +""+k + "+"+ m+""+n +" = 100 ");
						}
						
					}
					
				}
			}
		}
	}
	
	public static void showFor(String strChar[]) {
		int str_len = strChar.length;
		//int start_idx = (str_idx == 0) ? 1 : 0;
		int srart_idx = 1;
		int intChar[] = strToIntArray(strChar);
		
		
		for(int k=0; k<9; k++) {	
		
			System.out.println("showDecimal " + showDecimal(intChar, intChar.length));
		}

//		
//		for(int i=0; i<str_len; i++) {			
//			for(int k=0; k<9; k++) {	
//				
//				//System.out.println(i*Math.pow(10, str_len-1-i));
//				
//				System.out.println("strChar["+strChar[i]+",  i : " + i + ", k : " + k);
//			}						
//		}
	}
	
	public static int[] strToIntArray(String strChar[]) {
		
		int[] intArrays = new int[strChar.length];
		
		for(int i=0; i<strChar.length; i++) {
			intArrays[i] = Integer.parseInt(strChar[i]);
		}
		
		return intArrays;
	}
	
	public static int showDecimal(int i_arrs[], int idx) {
		
		if(idx == 1) {
			return i_arrs[0];
		}
		else {
			return showDecimal(i_arrs, idx-1);
		}
	}
	
	public static int getHasIdx(String s, String pqr) {
		
		return pqr.indexOf(s);
	}
	
	public static boolean isNum(String s) {		
		try {
			Integer.parseInt(s);			
			return true;
		} catch (NumberFormatException e) {
			
			return false;
		}		
	}

}
